import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 人力培训-入职记录信息 */
export interface TrainEntryLog {
  id: number; // 编号
  parentId: number; // 父id
  date: string | Dayjs; // 时间
  day: string; // 入职天数
  record: string; // 入职记录
  standard: string; // 培训标准
  summarize: string; // 总结
  judge: string; // 综合判断
  remark: string; // 备注
}

/** 人力培训-个人资料信息 */
export interface TrainPersonalDetails {
  id: number; // 编号
  userId?: number; // 用户
  deptId: number; // 部门
  superiorId: number; // 上级
  shopId: number; // 店铺
  entryTime?: string | Dayjs; // 入职日期
  education: string; // 学历
  age: number; // 年龄
  major: string; // 专业
  status: string; // 状态
  remark: string; // 备注
}

// 人力培训-个人资料 API
export const TrainPersonalDetailsApi = {
  // 查询人力培训-个人资料分页
  getTrainPersonalDetailsPage: async (params: any) => {
    return await request.get({ url: `/hr/train-personal-details/page`, params })
  },

  // 查询人力培训-个人资料详情
  getTrainPersonalDetails: async (id: number) => {
    return await request.get({ url: `/hr/train-personal-details/get?id=` + id })
  },

  // 新增人力培训-个人资料
  createTrainPersonalDetails: async (data: TrainPersonalDetails) => {
    return await request.post({ url: `/hr/train-personal-details/create`, data })
  },

  // 修改人力培训-个人资料
  updateTrainPersonalDetails: async (data: TrainPersonalDetails) => {
    return await request.put({ url: `/hr/train-personal-details/update`, data })
  },

  // 删除人力培训-个人资料
  deleteTrainPersonalDetails: async (id: number) => {
    return await request.delete({ url: `/hr/train-personal-details/delete?id=` + id })
  },

  /** 批量删除人力培训-个人资料 */
  deleteTrainPersonalDetailsList: async (ids: number[]) => {
    return await request.delete({ url: `/hr/train-personal-details/delete-list?ids=${ids.join(',')}` })
  },

  // 导出人力培训-个人资料 Excel
  exportTrainPersonalDetails: async (params) => {
    return await request.download({ url: `/hr/train-personal-details/export-excel`, params })
  },


  // ==================== 子表（人力培训-入职记录） ====================

  // 获得人力培训-入职记录分页
  getTrainEntryLogList: async (params) => {
    return await request.get({ url: `/hr/train-personal-details/train-entry-log/list`, params })
  },

  // 获得人力培训-入职记录详情
  getTrainEntryLog: async (id: number) => {
    return await request.get({ url: `/hr/train-personal-details/train-entry-log/get?id=` + id })
  },

  // 新增人力培训-入职记录
  createTrainEntryLog: async (data: TrainEntryLog) => {
    return await request.post({ url: `/hr/train-personal-details/train-entry-log/create`, data })
  },

  // 修改人力培训-入职记录
  updateTrainEntryLog: async (data: TrainEntryLog) => {
    return await request.put({ url: `/hr/train-personal-details/train-entry-log/update`, data })
  },

  // 删除人力培训-入职记录
  deleteTrainEntryLog: async (id: number) => {
    return await request.delete({ url: `/hr/train-personal-details/train-entry-log/delete?id=` + id })
  },
}
